#include "HiranipraShared.h"

#include "enet/enet.h"

#include "Net/Address.h"
#include "Net/Packet.h"
#include "Net/Peer.h"
#include "Net/NetEvent.h"

#ifndef _SHARED_NET_NETBASE_H_
#define _SHARED_NET_NETBASE_H_

namespace Hiranipra {
	namespace Net {

		class NetBase : implements RefInstance
		{
		public:
			NetBase();
			virtual ~NetBase();

			void SetBandwidthLimits( uint32 incomingBandwidth, uint32 outgoingBandwidth );
			bool Poll( uint32 timeout = INFINITE );
			void Flush();

			Packet* AllocatePacket( PacketFlags flags, uint32 size );

		public:
			EventSource<NetEvent>	EventSource;

		protected:
			virtual void OnConnect( ENetEvent& ev ) = 0;
			virtual void OnDisconnect( ENetEvent& ev ) = 0;

		protected:
			ENetHost*	_selfHost;
		};

	}
}

#endif // _SHARED_NET_NETBASE_H_
